﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
     <script src="<%: Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript"></script>
   <script src="<%: Url.Content("~/Scripts/jquery-1.4.4.min.js") %>" type="text/javascript"></script>
    <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-fly.js" type="text/javascript"></script>
    <title>List</title>

    <script type="text/javascript">
        function left(id) {
            var i = getWidth();
            var pos = $("#" + id).scrollLeft();
            $("#" + id).animate({ scrollLeft: pos + (200 * i) }, 'slow');
        }

        function getWidth() {
            return $(document).width() / 250;
        }

        function right(id) {
            var i = getWidth();
            var pos = $("#" + id).scrollLeft();
            $("#" + id).animate({ scrollLeft: pos - (200 * i) }, 'slow');
        }

        function expand(id) {
            var src = ($("#img_" + id).attr("src") == "../../images/collaps.png")
                    ? "../../images/expand.png"
                    : "../../images/collaps.png";

            $("#img_" + id).attr("src", src);
            $("#channel" + id).slideToggle();
        }

        function countt(ctrl) {
            var text = $("#" + ctrl).text().toString();
            if(text.length > 100) {
                $("#" + ctrl).text(text.substr(0,90) + "...") ;    
            } else {
            $("#" + ctrl).text(text);
            }
            
         //alert($("#counttext").text());
    }

    var readItemCount = 0;

    function addReadList(id, sender) {
    <%
    if (!Request.IsAuthenticated) {
    %>
        alert('Not logged in!')
        return;
    <%} %>
     
     var URL = "/User/AddToReadList/?id=" + id; 
     $.ajax({
            type: "POST",
            url: URL,
            data: "",
            success: function(text) {
                sender.className = "inreadlist";
                $("#item_" + id).flyOffPage({
                tween: {
                opacity: 50
                },
                direction: 'topRight'
        });
        readItemCount++;
            $("#rdListTxt").html("("+readItemCount +")");
            $("#rdListTxt").css("readlist");
            },
            error: function(text) {
                alert('Unable to add to Read list!');
            }
        });
      
      }

      

    </script>
</head>
<body>
    <% Html.RenderPartial("_Header"); %>
   
    <% foreach (var p in this.Model) { %><div class="channel">
    <div class="c-title hand" onclick="expand('<%=p.Id%>');">
        <table cellpadding=0 cellspacing=0><tr><td><img id="img_<%= p.Id %>" src="../../images/expand.png" /></td><td><%= p.Title %></td></tr></table></div><br />
        <% Html.RenderPartial("ChannelViewList", (Channels.Models.Channel)(p));%>
    </div>
    <%} %>
 </body>
</html>
